<%--
  Created by IntelliJ IDEA.
  User: carol
  Date: 2018/6/12
  Time: 17:22
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page language="java" import="java.util.*,javax.servlet.*,functest.*" pageEncoding="utf-8" %>
<html>
<head>
    <title>票务信息管理</title>
    <meta charset="UTF-8">
    <script type="text/javascript" src="js/jquery-3-2-1.js"></script>
    <link type="text/css" rel="stylesheet" href="layui/css/layui.css" media="all">
    <script type="text/javascript" src="layui/layui.all.js"></script>
    <link type="text/css" rel="stylesheet" href="css/style.css" media="all">
</head>
<body>
<div class="head" >
    <div class="head-text">
        <li class="title">航空票务系统</li>
    </div>
    <a href="index.jsp"><img class="logo" src="img/logo.png" ></a>
</div>
<div style="margin-top: 100px;">
    <ul class="layui-nav layui-nav-tree layui-nav-side" style="top: 60;">
    <li class="layui-nav-item">
        <a href="mgrcity.jsp">城市机场管理</a>
    </li>
    <li class="layui-nav-item layui-nav-itemed">
        <a href="mgrtk.jsp">票务信息管理</a>
    </li>
    <li class="layui-nav-item"><a href="mgrflight.jsp">航班管理</a></li>
</ul>
<div style="margin-left: 220px;margin-right: 20px">
    <blockquote class="layui-elem-quote">票务信息</blockquote>
    <table lay-filter="spxxtable">
        <thead>
        <tr>
            <th lay-data="{field:'tkid',align:'center',sort: true}">票务ID</th>
            <th lay-data="{field:'clientid',width:200,align:'center',sort: true}">身份证</th>
            <th lay-data="{field:'clientname',align:'center',sort: true}">顾客名称</th>
            <th lay-data="{field:'flightid',align:'center',sort: true}">航班编号</th>
            <th lay-data="{field:'startport',align:'center',sort: true}">起飞机场</th>
            <th lay-data="{field:'endport',align:'center',sort: true}">到达机场</th>
            <th lay-data="{field:'class',align:'center',sort: true}">舱位</th>
            <th lay-data="{field:'date',align:'center',sort: true}">起飞日期</th>
            <th lay-data="{field:'price',align:'center',sort: true}">价格</th>
            <th lay-data="{fixed: 'right', minWidth: 220, align:'center', toolbar: '#barspxx'}">操作</th>
        </tr>
        </thead>
        <tbody>
        <%
            FindAPrint func =new FindAPrint();
            List<Map<String,String>> spxx=func.Findspxx();
            for(Map<String,String> spxxmap:spxx) {
                out.println("<tr><td>"+ spxxmap.get("tkid") +"</td><td>"
                        + spxxmap.get("clientid") +"</td><td>"
                        + spxxmap.get("clientname") +"</td><td>"
                        + spxxmap.get("flightid") +"</td><td>"
                        + spxxmap.get("startport") +"</td><td>"
                        + spxxmap.get("endport") +"</td><td>"
                        + spxxmap.get("class") +"</td><td>"
                        + spxxmap.get("date") +"</td><td>"
                        + spxxmap.get("price") +"</td><td>");
                out.println("</td><td></td></tr>");
            }
        %>
        </tbody>
    </table>
    <div style="text-align: center">
        <a class="layui-btn layui-btn-primary" href="buypg1.jsp">前往买票</a>
        <a href="index.jsp" class="layui-btn layui-btn-normal">返回</a>
    </div>
</div>
</div>

</body>
</html>

<script type="text/html" id="barspxx">
    <a class="layui-btn layui-btn-radius layui-btn-xs" lay-event="edit">改签</a>
    <a class="layui-btn layui-btn-radius layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>
<script type="text/javascript">
    layui.use(['jquery','layer','table'], function(){
        var layer = layui.layer
            ,element = layui.element
            ,$= layui.$
            ,table=layui.table;

        //转换静态表格
        table.init('spxxtable', {cellMinWidth: 120,limit: 10,page:true});
        //监听工具条
        table.on('tool(spxxtable)', function(obj){
            var data = obj.data;
            var tk_id = data['tkid'];
            var delurl = 'deltk.jsp?tkid=' + tk_id;
            var name = data['clientname'];
            var userid = data['clientid'];
            var editurl = 'buypg1.jsp?tkid=' + tk_id + "&name=" + name +"&userid="+userid;
            if(obj.event === 'edit'){
                layer.open({
                    type: 2,
                    title: "用户改签",
                    content: editurl,
                    area: [window.innerWidth * 26 / 30 + "px", window.innerHeight * 26 / 30 + "px"],
                });
            }
            else if(obj.event === 'del'){
                layer.confirm('确定删除？', function(index){
                    $.get(delurl);
                    obj.del();
                    layer.msg('删除成功', {
                        icon: 6,
                        time: 500 //2秒关闭（如果不配置，默认是3秒）
                    });
                    layer.close(index);
                });
            }
        });
    });
</script>
